home *** CD-ROM | disk | FTP | other *** search
/ Acorn RISC PD-CD 1 / Acorn RISC PD-CD 1.iso / languages / hope / bnfhope next >
Encoding:
Text File  |  1990-04-25  |  8.7 KB  |  370 lines

  1. <program> ::=
  2.         <program element> <sep>..1..<program element> ;
  3.  
  4. <program element> ::=
  5.         <module> |
  6.         <context command> |
  7.         <statement>
  8.  
  9. <sep> ::=
  10.         ;
  11.  
  12. <module> ::=
  13.         module <module name> <sep>  <statement> <sep> ..0.. <statement> end
  14.  
  15. <statement> ::=
  16.         <system command>  |
  17.         <syntax declaration> |
  18.         <scope command> |
  19.         <interface declaration> |
  20.         <type-variable declaration> |
  21.         <defined-object declaration> |
  22.         <type definition statement> |
  23.         <equation> |
  24.         <comment>
  25.  
  26. <system command> ::=
  27.         load <file name> |
  28.         exit |
  29.         echo <onoff parameter> |
  30.         trace <trace parameter> |
  31.         notrace <notrace parameter> |
  32.         save <file name> |
  33.         time <onoff parameter> |
  34.         system |
  35.         help |
  36.         display <display parameter> |
  37.         ^C
  38.  
  39. <display parameter> ::=
  40.         data |
  41.         functions |
  42.         <identifier> |
  43.         <identifier> * |
  44.         <empty>
  45.  
  46. <trace parameter> ::=
  47.         <identifier> *? |
  48.         on |
  49.         off |
  50.         all
  51.  
  52. <notrace parameter> ::=
  53.         <identifier> *? |
  54.         all
  55.  
  56. <onoff parameter> ::=
  57.  
  58.  
  59. >
  60.  
  61. <empty> :=
  62.  
  63. <syntax declaration> ::=
  64. <identifier> , ..1.. <identifier> : <precedence>
  65.  
  66. <precedence> ::=
  67.         <natural number>
  68.  
  69. <interface declaration> ::=
  70.         <export declaration> |
  71.         <import declaration>
  72.  
  73. <export declaration> ::=
  74.         <export declaration kind> <identifier> , ..1.. <identifier>
  75.  
  76. <export declaration kind> ::=
  77.         pubtype |
  78.         pubconst
  79.  
  80. <import declaration> ::=
  81.         uses <identifier> , ..1.. <identifier>
  82.  
  83. <type-variable declaration> ::=
  84.         typevar <identifier> , ..1.. <identifier>
  85.  
  86. <defined-object declaration> ::=
  87.         dec <identifier> , ..1.. <identifier> : <type expression>
  88.  
  89. <type definition statement> ::=
  90.         data <primitive type definition> with ..1.. <primitive type definition> |
  91.         type <derived type definition>
  92.  
  93. <primitive type definition> ::=
  94.         <formal type term> == <type summand> ++ ..1.. <type summand>
  95.  
  96. <derived type definition> ::=
  97.         <formal type term> == <type expression>
  98.  
  99. <formal type term> ::=
  100.         <type constant> |
  101.         <non-operator type constructor> <type variable> |
  102.         <non-operator type constructor> ( <type variable> , ..0.. <type variable> ) |
  103.         <prefix type constructor> <type variable> |
  104.         <type variable> <infix type constructor> <type variable> |
  105.         ( <formal type term> )
  106.  
  107.  
  108. <type summand> ::=
  109.         <data constant> |
  110.         <non-operator data constructor> <type expression> |
  111.         <prefix data constructor> <type expression> |
  112.         <type expression> <infix data constructor> <type expression> |
  113.         ( <type summand> )
  114.  
  115. <type expression> ::=
  116.         <simple type expression> |
  117.         <constructor type expression> |
  118.         <function type expression> |
  119.         <tuple type expression> |
  120.         ( <type expression> )
  121.  
  122. <simple type expression>::=
  123.         <type variable> |
  124.         <type constant>
  125.  
  126. <constructor type expression> ::=
  127.         <non-operator type constructor> <type expression> |
  128.         <non-operator type constructor> ( <type expression> , ..1.. <type expression> ) |
  129.         <prefix type constructor> <type expression> |
  130.         <type expression> <infix type constructor> |
  131.         <type expression>
  132.  
  133. <function type expression> ::=
  134.         <type expression> -> <type expression>
  135.  
  136. <tuple type expression> ::=
  137.         <type expression> # ..2.. <type expression> |
  138.         void
  139.  
  140. <equation> ::=
  141.         --- <formal defined-object term> <= <expression>
  142.  
  143. <formal defined-object term> ::=
  144.         <simple formal defined-object term> |
  145.         <application formal defined-object term>
  146.  
  147. <simple formal defined-object term> ::=
  148.         <non-operator defined-object>
  149.  
  150. <application formal defined-object term> ::=
  151.         <non-operator defined-object> <pattern> |
  152.         <prefix defined-object> <pattern> |
  153.         <pattern> <infix defined-object> <pattern>
  154.  
  155. <pattern> ::=
  156.         <simple pattern> |
  157.         <pattern tuple> |
  158.         <data constructor pattern |
  159.         <non-operator variable> & <pattern> |
  160.         ( <pattern> )
  161.  
  162. <simple pattern> ::=
  163.         <literal> |
  164.         <non-operator variable> |
  165.         <data constant> |
  166.         _
  167.  
  168. <pattern tuple> ::=
  169.         <pattern> , ..0.. <pattern> |
  170.         ( )
  171.  
  172. <data constructor pattern> ::=
  173.         <non-operator data constructor> <pattern> |
  174.         <prefix data constructor> <pattern> |
  175.         <pattern> <infix data constructor> <pattern>
  176.  
  177. <expression> ::=
  178.         <simple expression> |
  179.         <application expression> |
  180.         <conditional expression> |
  181.         <qualified expression> |
  182.         <lambda expression> |
  183.         <tuple expression> |
  184.         <list expression> |
  185.         <set expression> |
  186.         ( <expression> )
  187.  
  188. <simple expression> ::=
  189.         <literal> |
  190.         <non-operator variable> |
  191.         <data constant> |
  192.         <non-operator data constructor> |
  193.         <non-operator defined-object>
  194.  
  195. <application expression> ::=
  196.         <expression> <expression> |
  197.         <prefix operator> <expression> |
  198.         <expression> <infix operator> <expression>
  199.  
  200. <conditional expression> ::=
  201.         <cond pair> else <expression>
  202.  
  203. <cond pair> ::=
  204.         <expression> if <boolean expression> |
  205.         <boolean expression> then <expression> |
  206.         if <boolean expression> then <expression>
  207.  
  208. <boolean expression> ::=
  209.         <expression>
  210.  
  211. <qualified expression> ::=
  212.         let <pattern> == <expression> in <expression> |
  213.         <expression> where <pattern> == <expression>
  214.  
  215. <lambda expression> ::=
  216.         <lambda mark> <lambda rule> | ..1.. <lambda rule>
  217.  
  218. <lambda rule> ::=
  219.         <pattern> => <expression>
  220.  
  221. <lambda mark > :: =
  222.         lambda
  223.  
  224. <tuple expression> ::=
  225.         <expression> , ..0.. <expression> |
  226.         ( )
  227. <list expression> ::=
  228.         [ <expression> , ..0.. <expression> ]
  229.  
  230. <set expression> ::=
  231.         { <expression> , ..0.. <expression> }
  232.  
  233. <non-operator type constructor> ::=
  234.         <non-operator identifier phrase>
  235.  
  236. <prefix type constructor> ::=
  237.         <prefix identifier>
  238.  
  239. <infix type constructor> ::=
  240.         <infix identifier>
  241.  
  242. <type constant> ::=
  243.         <non-operator identifier>
  244.  
  245. <type variable> ::=
  246.         <non-operator identifier>
  247.  
  248. <prefix operator> ::=
  249.         <prefix data constructor> |
  250.         <prefix defined-object> |
  251.         <prefix variable>
  252.  
  253. <infix operator> ::=
  254.         <infix data constructor> |
  255.         <infix defined-object> |
  256.         <infix variable>
  257.  
  258. <non-operator data constructor> ::=
  259.         <non-operator identifier phrase>
  260.  
  261. <prefix data constructor> ::=
  262.         <prefix identifier>
  263.  
  264. <infix data constructor> ::=
  265.         <infix identifier>
  266.  
  267. <data constant> ::=
  268.         <non-operator identifier>
  269.  
  270. <non-operator defined-object> ::=
  271.         <non-operator identifier phrase>
  272.  
  273. <prefix defined-object> ::=
  274.         <prefix identifier>
  275.  
  276. <infix defined-object> ::=
  277.         <infix identifier>
  278.  
  279. <module name> ::=
  280.         <identifier>
  281.  
  282. <file name> ::=
  283.         <alphanumeric identifier> |
  284.         "<system file identifier>"
  285.  
  286. operator identifier phrase> ::=
  287.         <non-operator identifier> |
  288.         nonop <operator identifier>
  289.  
  290. <non-operator identifier> ::=
  291.         <identifier>
  292.  
  293. <operator identifier> ::=
  294.         <prefix identifier> |
  295.         <infix identifier>
  296.  
  297. <prefix identifier> ::=
  298.         <identifier>
  299.  
  300. <infix identifier> ::=
  301.         <identifier>
  302.  
  303. <literal> ::=
  304.         <natural number literal> |
  305.         <boolean literal> |
  306.         <character literal> |
  307.         <character list literal>
  308.  
  309. <natural number literal> ::=
  310.         <natural number>
  311.  
  312. <boolean literal> ::=
  313.         true |
  314.         false
  315.  
  316. <character literal> ::=
  317.         '<any ASCII character>' |
  318.         crlf
  319.  
  320. <character list literal> ::=
  321.         "<any ASCII character (except use  \n to denote crlf; use \\ to denote \'>"
  322.  
  323. <comment> ::=
  324.         ! <any sequence of printable ASCII characters terminated by ! or the end of line>
  325.  
  326. <non-keyword text item> ::=
  327.         <any <text item> that is not a <keyword>>
  328.  
  329. <keyword> ::=
  330.         module | end | infix | prefix |
  331.         pubtype | pubconst  | uses |
  332.         typevar | dec | var | data | type | --- | let  |
  333.         exit  | echo  | trace  | notrace | load | display | system
  334.  
  335. <text item> ::=
  336.         <identifier> |
  337.         <natural number> |
  338.         <punctuation sign>
  339.  
  340. <identifier> ::=
  341.         <alphanumeric identifier> |
  342.         <compound sign identifier>
  343.  
  344. <alphanumeric identifier> ::=
  345.         <letter> <alphanumeric *?>
  346.  
  347. <compound sign identifier> ::=
  348.         <compoundable sign *>
  349.  
  350. <natural number> ::=
  351.         <digit *>
  352.  
  353. <alphanumeric> ::=
  354.         <letter> |
  355.         <digit>
  356.  
  357. <letter> ::=
  358.         A .. Z |
  359.         a .. z |
  360.         _
  361.  
  362. <digit> ::=
  363.         0 .. 9
  364.  
  365. <compoundable sign> ::=
  366.         #  |  $  |  |  |  &  |  *  |  +  |  -  |  .  |  /  |  :  |  <  |  =  |  >  |  ?  |  \
  367.  
  368. <punctuation sign> ::=
  369.         (  |  )  |  ,  |  ;  |  [  |  ]  |  {  |  }
  370.